<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- <%@ page import="java.text.SimpleDateFormat"%>  --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询销售卡明细</title>
<%@ include file="/common/importLib.jsp" %>
<script type="text/javascript" src="../common/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">

	/**
	 * 增删改查参数设置
	 */
	/* toolbarView = 0;
	tableWidth = "100%";
	tableHeight = $(window).height()-110; */
	toolbarView = 2;
	tableTitle = "销售卡明细";
	var addWidth = 550; //添加窗口宽度
	var addHeight = 350; //添加窗口高度
	var addTitle = "批量生成销售卡"; //添加标题
	var updateDisableFlagUri = "../maintain/salesCard/updateDisableFlag.do"; //禁用、起用记录
	//var deleteUri = "/deleteByIds.do"; //删除记录
	tableURL = getTimeURL("../maintain/salesCard/getCardListByPage.do");
	tableColumns = [[{field:'ck',checkbox:true},
	                {field:'id',title:'id',width:0},
					{field:'salesCardName',title:'卡名称',width:180},
					//{field:'money',title:'价格（元）',width:70,rowspan:2},
					{field:'activationCode',title:'激活密码',width:150,align:'center'},
					{field:'expiryDateString',title:'激活失效时间',width:150,align:'center'},
					{field:'addDateString',title:'添加时间',width:150,align:'center'},
					{field:'activationStatus',title:'激活状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.activationStatus == 1){
								return "<font color='red'>已激活</font>";
							}else{
								return "<font color='green'>未激活</font>";
							}
						}
					},
					{field:'disableFlag',title:'禁用状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.disableFlag == 0){
								return "<font color='green'>起用</font>";
							}else{
								return "<font color='red'>禁用</font>";
							}
						}
					}]]; 
	
	$(function(){
		combobox_select_event("activationStatus","../maintain/salesCard/getCardStatusList.do",true,"",function(){
			searchTable();
		});
		//combobox_1("paymentMethod","../payment/userBalance/getPayMethodList.do",false);
		$("#exportXls").on('click',exportXls);
	});
	
	/*function searchTable(){
		 var pp = $('#tt').tabs('getSelected');   
		 var tab = pp.panel('options').tab; 
		 createTable(tab.text());
	}*/
	
	/**
	 * 初始化添加表单
	 */	
	function initAddForm(){	
		addFormProcess("salesNum","销售卡",true,function(data){
			if(data>0){						
				$('#datagrid_add').window('close');  //关闭添加窗口
				$.messager.alert("添加成功","销售卡信息批量添加成功！数量为"+data,'info');  //提示添加信息成功							
				loadFirstPageData(); //重新装载第1页数据
			}else{
				$.messager.alert("添加失败","销售卡信息批量添加失败，请联系客服！",'info');  //提示添加信息成功
			}
		});	
		numFormValidator("salesNum","销售卡数目",1,5000,"intege1");
	}
	
	function exportXls(){
		var activationStatus=$('input[name="activationStatus"]').val();
		var startTime = $("#starttime").val();
		var endTime = $("#endtime").val();
		var disableFlag = $("#disableFlagQuery option:selected").val();
		$.messager.confirm('导出', '是否导出销售卡的表格？' ,function(r){
			if(r){
				location.href=getTimeURL("../maintain/salesCard/exportCardBack.do?startTimeString=" + startTime +"&endTimeString="+ endTime+"&activationStatus="+activationStatus+"&disableFlag="+disableFlag);		
			}
		});
   }

</script>
</head>
<body id="layout" class="easyui-layout">
	<div style="background: none repeat scroll 0% 0% #EFEFEF; height:100px; padding: 6px 2px; border-bottom: 1px solid #CCC;"
		region="north"  split="false" title="条件查询">
	<form  id="searchForm" >
	<table>
		<tr>
			<td width ="30px;"></td>
			<td>添加时间：</td><td><input type="text" name="startTimeString" id="starttime" style="width: 86px;" class="input-style Wdate" onclick="WdatePicker({el:'starttime',maxDate:'#F{$dp.$D(\'endtime\')}'})"/>
			<span style="padding: 0 6px 0 2px;">至</span><input type="text" name ="endTimeString" id="endtime"  style="width: 86px;" class="input-style Wdate" onclick="WdatePicker({el:'endtime',minDate:'#F{$dp.$D(\'starttime\')}'})"/></td>
			<td width="50px;"></td>
			<td>激活状态：</td><td><input type="text" name="activationStatus" id="activationStatus"/></td>
			<td></td>
		</tr>
		<tr>		
			<td width ="30px;"></td>
			<td>卡密码：</td><td><input type="text" name="activationCode" id="activationCode"/></td>	
			<td width="50px;"></td>
			<td>启用状态：</td>
			<td>
				<select id="disableFlagQuery"  name="disableFlag" class="easyui-combobox" style="width:153px" >
					<option value = "0"> 启用 </option>
					<option value = "1"> 禁用</option>
				</select>
			</td>	
			<td width="50px;"></td>
			<td><a class="easyui-linkbutton" id="search" iconCLs="icon-search"  onclick="searchTable();">搜索</a></td>
			<!--<td><a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('searchForm').reset();">清空</a></td>-->
			 <td><a class="easyui-linkbutton" iconCLs="icon-excel" id="exportXls">导出</a></td> 
		</tr>
	</table>
	</form>
	</div>
	<div region="center">
		<!-- datagrid信息表 -->
		<table id="datagrid_table"></table>
		
		<!-- 添加记录 -->
		<style>
			#datagrid_add,#datagrid_update{
				padding:  10px 20px;
			}
		
			#datagrid_add tr,#datagrid_update tr{
			    height: 50px;
			}
			
		</style>
		<div id="datagrid_add">
			<form id="add_form" action="../maintain/salesCard/generateCardBatch.do" method="post">
				<table width="500" class="xxl_tb_1">
					<tbody>	
						<tr>
							<td class="xxl_td_2">销售卡数目：</td>
							<td ><input type="text" id="salesNum" name="id"/></td>
							<td><div id="salesNumTip" style="width:150px"></div></td>
						</tr>
						<!-- <tr>
							<td class="xxl_td_2">销售卡名称：</td>
							<td ><input type="text" id="salesNum" name="id"/></td>
							<td><div id="salesNumTip" style="width:150px"></div></td>
						</tr> -->
						<tr >
							<td class="xxl_td_2">销售卡失效时间：</td>
							<td><input id='expiryDate' type='text' name='expiryDateString' class="Wdate" onclick="WdatePicker({el:'expiryDate',minDate:'%y-%M-{%d+1}'})" /></td>	
							<td><div id="expiryDateTip" style="width:150px">（不填时为一年后的今天）</div></td>
						</tr>
						<tr>
							<td colspan="3" style="text-align: center">					
								<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#add_form').submit();">添加</a>
								<a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('add_form').reset()">重置</a>
								<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_add').window('close');">取消</a>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
</body>
</html>